package com.mini.mini.controller;

import com.alibaba.fastjson.JSON;
import com.mini.entity.Result;
import com.mini.mini.entity.DoubleElephant;
import com.mini.mini.entity.TEpidemicNewsInfoCopy;
import com.mini.mini.service.TEpidemicNewsInfoCopyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hy
 * @since 2021-05-08
 */
@RestController
@CrossOrigin
@RequestMapping("/mini/t-epidemic-news-info-copy")
public class TEpidemicNewsInfoCopyController {
    @Autowired
    private TEpidemicNewsInfoCopyService tEpidemicNewsInfoCopyService;

    @PostMapping
    public Result add(TEpidemicNewsInfoCopy tEpidemicNewsInfoCopy) {
        List<DoubleElephant> list = new ArrayList<>();
        DoubleElephant de1 = new DoubleElephant();
        DoubleElephant de2 = new DoubleElephant();
        de1.setFlag(1);
        de1.setTitle("文字");
        de2.setTitle("图片链接");
        de2.setFlag(2);
        list.add(de1);
        list.add(de2);
        String s1 = JSON.toJSONString(list);
        tEpidemicNewsInfoCopy.setInfo(s1);
        tEpidemicNewsInfoCopyService.save(tEpidemicNewsInfoCopy);
        return Result.success();
    }

}

